namespace Collaboris.Saf.Actions.Wss.Tests.Generated
{
    using Engine.Report;

    using Microsoft.SharePoint;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Saf.Tests;
    using Entities;
    using Column;

    using SharePoint.Wss.Columns;

    /// <summary>
    /// This test was originally generated but has now been tested and verfiied by MJ
    /// </summary>
    [TestClass]
    public class EnsureSiteColumnTest
    {
        [TestMethod]
        public void EnsureSiteColumn_Test()
        {
            WSSTestAssistant<EnsureSiteColumn, ElementsInfo> ensuresitecolumn =
                    new WSSTestAssistant<EnsureSiteColumn, ElementsInfo>(TestEnvironment.PublishingSite, 
                        "EnsureSiteColumnTestWeb", "BLANKINTERNET#0");

            using (ensuresitecolumn)
            {
                ensuresitecolumn.FirstEntity.FilePath = ensuresitecolumn.FirstSupportingFilePath;

                // this inserts the fields
                MacroReport doReport = ensuresitecolumn.DoMacro();

                SPField field = null;
                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "Customer");
                Assert.IsTrue(field.StaticName == "Customer");
                Assert.IsTrue(field.Group == "SAF Tests");
                Assert.IsTrue(field.ReadOnlyField == false);
                Assert.IsTrue(field.Sealed == false);
                Assert.IsTrue(field.Type == SPFieldType.Text);

                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "SID");
                Assert.IsTrue(field.StaticName == "SID");
                Assert.IsTrue(field.Group == "SAF Tests");
                Assert.IsTrue(field.ReadOnlyField == true);
                Assert.IsTrue(field.Type == SPFieldType.Counter);

                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "Changed");
                Assert.IsTrue(field.StaticName == "Changed");
                Assert.IsTrue(field.Group == "SAF Tests");
                Assert.IsTrue(field.ReadOnlyField == false);
                Assert.IsTrue(field.Type == SPFieldType.DateTime);

                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "Writer");
                Assert.IsTrue(field.StaticName == "Writer");
                Assert.IsTrue(field.Group == "SAF Tests");
                Assert.IsTrue(field.ReadOnlyField == true);
                Assert.IsTrue(field.Type == SPFieldType.User);

                SPFieldChoice fieldchoice = (SPFieldChoice)SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "ChoiceCol");
                Assert.IsTrue(fieldchoice.StaticName == "ChoiceCol");
                Assert.IsTrue(fieldchoice.Group == "SAF Tests");
                Assert.IsTrue(fieldchoice.ReadOnlyField == false);
                Assert.IsTrue(fieldchoice.Type == SPFieldType.Choice);
                Assert.IsTrue(fieldchoice.Choices[0] == "Level1");
                Assert.IsTrue(fieldchoice.Choices[1] == "Level2");

                // same as the insert file - but this is to update it!
                ensuresitecolumn.FirstEntity.FilePath = ensuresitecolumn.SupportingFiles[1];
                doReport = ensuresitecolumn.DoMacro();

                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "Customer");
                Assert.IsTrue(field.StaticName == "CustomerUpdate1234");
                Assert.IsTrue(field.Group == "SAF Tests Update");
                Assert.IsTrue(field.ReadOnlyField == true);
                Assert.IsTrue(field.Sealed == true);
                Assert.IsTrue(field.Type == SPFieldType.Text);


                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "SID");
                Assert.IsTrue(field.StaticName == "SIDUpdate");
                Assert.IsTrue(field.Group == "SAF Tests Update");
                Assert.IsTrue(field.ReadOnlyField == true);
                Assert.IsTrue(field.Type == SPFieldType.Counter);

                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "Changed");
                Assert.IsTrue(field.StaticName == "ChangedUpdate");
                Assert.IsTrue(field.Group == "SAF Tests Update");
                Assert.IsTrue(field.ReadOnlyField == false);
                Assert.IsTrue(field.Type == SPFieldType.DateTime);

                field = SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "Writer");
                Assert.IsTrue(field.StaticName == "WriterUpdate");
                Assert.IsTrue(field.Group == "SAF Tests Update");
                Assert.IsTrue(field.ReadOnlyField == true);
                Assert.IsTrue(field.Type == SPFieldType.User);

                fieldchoice = (SPFieldChoice)SiteColumnHelper.GetField(ensuresitecolumn.TestWeb, "ChoiceCol");
                Assert.IsTrue(fieldchoice.StaticName == "ChoiceColUpdate");
                Assert.IsTrue(fieldchoice.Group == "SAF Tests Update");
                Assert.IsTrue(fieldchoice.ReadOnlyField == false);
                Assert.IsTrue(fieldchoice.Type == SPFieldType.Choice);
                Assert.IsTrue(fieldchoice.Choices[0] == "Level1Update");
                Assert.IsTrue(fieldchoice.Choices[1] == "Level2Update");
                Assert.IsTrue(fieldchoice.Choices[2] == "Level3Update");
                Assert.IsTrue(fieldchoice.DefaultValue == "Level2Update");

            }
        }

    }
}
